�� ������ Move Members �����丵 ������ ��ſ��� �������� overview�� �����ϰ� how �� �����丵�� IntelliJ
IDEA���� ���� �� �ִ°��� �����մϴ�.
IDEA����, �� �����丵�� ����ϸ� ����� ������ �ʵ�, �޼ҵ� �Ǵ� ���� Ŭ������ �� �ٸ� Ŭ������ ������ �ű�ϴ�. �� �����, ������ �޼ҵ�, �ʵ� �Ǵ� ���� Ŭ������ �� �ٸ� ��ġ�� �Ű����� �����ϴ� ������ ������Ʈ�˴ϴ�.
���� ���, �츮�� ���� Ŭ������ �����ϴ�:
public class AClass {
public static void methodA() {
//some code here
}
public void methodB() {
//some code here
methodA();
}
}
�׸��� ����� ������ methodA �� AnotherClass �� �̵��ϴ� ���� �����մϴ�, �װ��� �̰Ͱ� ���� ���Դϴ�:
public class AnotherClass {
}
�׸��� �̰��� ����� Ŭ������ �����丵�� ������ ����Դϴ�:
public class AClass {
public void methodB() {
//some code here
AnotherClass.methodA();
}
}
...
public class AnotherClass {
public static void methodA() {
//some code here
}
}
Ŭ���� ����� �ű�� ���ؼ�:
1. Project ���⿡��:
������ �ʵ�/�޼ҵ�/���� Ŭ������ �����ϰ� Ŭ���� ����� ������ ��ư Ŭ���ϴ� �Ϳ� ���� �ҷ����� �˾� �޴� ���� Refactor |
Move... �� Ŭ���Ͻʽÿ�.

|
����� �޼ҵ�, �ʵ� �Ǵ� ���� Ŭ������ �����ϱ� ���� � �ٸ� ���⸦ ����� �� �ֽ��ϴ�, ���� ��� Structure.
|
editor ���� :
�̵��ϰ� �� ������ �ʵ�/�޼ҵ�/���� Ŭ�������� ij���� �����ϰ� �� �޴����� �Ǵ� �����Ϳ��� ������ ��ư�� Ŭ���ϴ� �Ϳ� ���� �ҷ����� �˾� �޴� ���� Refactor
| Move...�� Ŭ���Ͻʽÿ�.

|
����� ������ ���� Ŭ������ �ű���� �ϰ� ���� ��, ������ ���� Ŭ������ ���� �����丵�� �����ϸ� ����� ������ ���̾�α׸� �� ���Դϴ�:
|

���� ���� Ŭ������ ���� �������� �Ű����� Move Inner to Upper �����丵�� ���ʽÿ�.
2. Move
Members ���̾�αװ� ��Ÿ���ϴ�:

Move members
from
|
�� �ʵ�� ��� ����� �Ű������� Ŭ������ �������ϴ�.
|
To (fully qualified
name):
|
���⿡�� ����� Ÿ�� Ŭ������ ���� ���ĵ� �̸��� ������ �� �ְų�, ellipsis��ư�� ������ �ʿ��� Ÿ�� Ŭ������ �߰��ϵ��� Choose
Destination Class ���̾�α׸� �θ� �� �ֽ��ϴ�:


|
���� �׷� �̸��� �ִ� � Ŭ������ ������
IDEA�� ���ο� Ŭ������ ������ ���� ������ ���Դϴ�.
|
|
Members to be
moved (static only)
|
�� ��Ͽ��� ����� �����ϴ� üũ �ڽ��� �����ϴ� �Ϳ� ���� �̵��Ǵ� Ŭ���� ����� ������ �� �ֽ��ϴ�.
|
Preview usages to
be changed
|
�� üũ �ڽ��� �����ϸ� ����� � ����� �߰ߵǾ����� �����ϰ�, �׵��� ��ü�� �����ϵ��� ����մϴ�. �� üũ �ڽ��� ���õ��� ���� ��, IDEA�� ��ü ��ɸ� �ڵ������� �����մϴ�.

|
������ üũ �ڽ��� ���õ��� �ʾ��� ����, ���� �߰ߵ� ����� � �б� ���� ���Ͽ��� �����ϸ� ��ü ����� Ȯ���ϴ� ������Ʈ�� ��ſ� ���� �� �Դϴ�.
|
Refactoring
Preview ���̾�α׿��� (���� �װ��� ��Ÿ����) ����� ����� ������ �м��� �� �ֽ��ϴ�. �����丵�� �Բ� �����ϱ� ���ؼ�, Do
Refactor�� Ŭ���մϴ�, �׷��� �ʴٸ� Cancel �� Ŭ���մϴ�. ���� ���� ������ Refactoring
Preview�� ���ʽÿ�.
|
|
3. OK�� �����ϴ�, �׸��� ���ϴ� ����� �̵��� ���Դϴ�.
4. ����� �̵��Ϸ��� �õ��ϸ�, ����� ������ �޼ҵ�/�ʵ�/���� Ŭ����(���� ��� �׵��� ������ �Ǵ� ���� ��Ű���� �� �� �ֽ��ϴ�)�� �̵��ϱ⸦ ���� �� ����� �ٸ� �޼ҵ� �Ǵ� ���� Ŭ����(���� ���, �������� �Ǵ� ���� ��Ű��)���� �׸��� �׵��� �ҽ� ��ġ�� ó�������� �����丵 �Ŀ� �װ����� ������ ���� �ݴ뿡�� ������ �޴� ������ �޼ҵ�/�ʵ�/���� Ŭ������ �� ��ġ�Ϸ��� �ϴ� ������ �ε�ĥ���� �𸨴ϴ�. �׸��� ���õ� �ڵ�� �̵����� �ʽ��ϴ�
���� ���:
public class AClass {
private static int a = 0;
public static void f1(){
a = 1;
f2();
}
private static void f2(){
//some code here
}
}
���� ����� �޼ҵ� f2()�� �ƴ� �޼ҵ� f1() �� �̵���Ű���� �մϴ� .
�׶� ������ Problems Detected ���̾�αװ� ��Ÿ���ϴ� .

���� ����� Cancel (����Ʈ)�� ������, ����� Move
Members ���̾�α׿��� �ڷ� �� ���Դϴ�. �ű⼠����� ������ �ַ���� ���� Ž���� �� �ֽ��ϴ�:
�ǽɽ����� ����� �̵����� �ʽ��ϴ�(����- f1());
���� ����� ���õ� �ٸ� ���� �̵��մϴ�. (����- f2() )l;
Move Members �����丵�� ����ϰ�, ����� �ڵ带 �������� �����ϰ�, ���ϴ� ����� �ٽ� �ű���� �մϴ�.
���� ����� Continue�� ������, ���ϴ� ����� �Ű��� �������� ������ �ϱ� ���ؼ� ����� �ڵ带 �������� ������ ���� ���Դϴ�.
|